package com.jerry.huihome.module.find.fragment;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.os.Bundle;

import com.jerry.huihome.R;
import com.jerry.huihome.base.BaseFragment;
import com.jerry.huihome.utils.EventMessage;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/5/10.
 */
public class ConstructionFragment extends BaseFragment {

    @BindView(R.id.iv_up_left_white)
    ImageView ivUpLeftWhite;
    @BindView(R.id.iv_up_right_white)
    ImageView ivUpRightWhite;

    private boolean isDesignerSelect = true;
    private boolean isForemanSelect = false;
    private PermanentFragment permanentFragment = BaseFragment.newInstance(PermanentFragment.class,null);

    public void showImg(){
        if (isDesignerSelect == true){
            ivUpLeftWhite.setVisibility(View.VISIBLE);
            ivUpRightWhite.setVisibility(View.INVISIBLE);
        }else {
            ivUpLeftWhite.setVisibility(View.INVISIBLE);
            ivUpRightWhite.setVisibility(View.VISIBLE);
        }
    }

    private String tag;

    @Override
    protected int getLayoutId(){
        return R.layout.fragment_construction_select;
    }

    @Override
    protected void initViews(){
        if(tag == "place"){
            PlaceFragment placeFragment = BaseFragment.newInstance(PlaceFragment.class, null);
            getChildFragmentManager().beginTransaction().replace(R.id.fl_construction, placeFragment).commit();
        }else{
            getChildFragmentManager().beginTransaction().replace(R.id.fl_construction, permanentFragment).commit();
        }
    }

    @OnClick(R.id.tv_permanent)
    public void onClickPermanent(TextView textView){
        getChildFragmentManager().beginTransaction().replace(R.id.fl_construction,permanentFragment).commit();
        isDesignerSelect = true;
        isForemanSelect = false;
        showImg();
    }

    @OnClick(R.id.tv_place)
    public void onClickPlace(TextView textView){
        PlaceFragment placeFragment = BaseFragment.newInstance(PlaceFragment.class,null);
        getChildFragmentManager().beginTransaction().replace(R.id.fl_construction,placeFragment).commit();
        isForemanSelect = true;
        isDesignerSelect = false;
        showImg();
    }
    @Override
    protected void getReqParams(Bundle bundle){
        tag = bundle.getString("tag");
    }

}
